package com.wusuowei.shiro_jwt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wusuowei.shiro_jwt.mapper.CategoryMapper;
import com.wusuowei.shiro_jwt.model.po.Category;
import com.wusuowei.shiro_jwt.model.po.Product;
import com.wusuowei.shiro_jwt.model.po.Role;
import com.wusuowei.shiro_jwt.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Slf4j
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
    /*@Transactional*/
    @Autowired
    private CategoryMapper categoryMapper;
    public List<Category> getAllCategories() {
        return this.list();
    }


    @Override
    public Category getCategory(String cid) {
        QueryWrapper<Category> wrapper = new QueryWrapper<>();
        wrapper.eq("id", cid);
        return categoryMapper.selectOne(wrapper);
    }

    @Override
    public Page<Category> findPage(Page<Category> page, String cname) {
        return categoryMapper.findPage(page, cname);
    }

    @Override
    public Category getCategoryById(Integer id) {
        return categoryMapper.getCategoryById(id);
    }
}
